import configparser
import os

#找到配置文件config.ini路径
config_path = os.path.join(os.path.split(os.path.realpath(__file__))[0],"config.ini")

#实例化configparser类，读出配置文件中的内容
conf = configparser.ConfigParser()
conf.read(config_path,encoding='utf-8')

class ReadConfig():
    #获取url地址
    def get_url(self,name):
        value = conf.get("URL",name)
        return value

    #获取邮件地址
    def mail_url(self,name):
        value = conf.get('EMAIL',name)
        return value

    # 获取数据库相关配置
    def get_db(self, name):
        value = conf.get("DATABASE", name)
        return value

    # 获取账号密码
    def get_account(self, name):
        value = conf.get("ACCOUNT", name)
        return value

    def get_dingding(self, name):
        value = conf.get("DINGDING", name)
        return value

if __name__ == "__main__":
    print(ReadConfig().get_url("test_http_url"))

